Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support octal, hex, and arbitrary radix numbers #140

Merged
merged 10 commits into from
Dec 26, 2024

Conversation

jianlingzhong
Copy link
Contributor

code is a bit ugly but should work:

❯ build/jank repl
Bottom of clojure.core
clojure.core=> 071
57
clojure.core=> -071
-57
clojure.core=> 08
Read error (0 - 2): invalid number: char 8 are invalid for radix 8
clojure.core=> 08.9
8.9
clojure.core=> 08e2
800
clojure.core=> 0-7.1
0
clojure.core=> 0xabc
2748
clojure.core=> 0Xabc
2748
clojure.core=> -0xef
-239
clojure.core=> 0xg
Read error (0 - 3): invalid number: char g are invalid for radix 16
clojure.core=> 0x-a
Read error (0 - 4): invalid number: char - are invalid for radix 16
clojure.core=> 2r011110
30
clojure.core=> 8r71
57
clojure.core=> -8r71
-57
clojure.core=> 1r0
Read error (0 - 3): invalid number: radix 1 is out of range
clojure.core=> -36razxyu
-18473142
clojure.core=> -30razxyu
Read error (0 - 9): invalid number: char zxyu are invalid for radix 30
clojure.core=> 37rzb
Read error (0 - 5): invalid number: radix 37 is out of range
clojure.core=> 36r4.5
Read error (0 - 6): invalid number: char . are invalid for radix 36
clojure.core=> 36r-4.5
Read error (0 - 7): invalid number: char -. are invalid for radix 36
clojure.core=> 3e-4
0.0003
clojure.core=> 16r3e4
996
clojure.core=>  36r3e4
4396
clojure.core=> 3e2/3
Read error (0 - 3): invalid ratio
clojure.core=> 7r3e4
Read error (0 - 5): invalid number: char e are invalid for radix 7
clojure.core=>  0xe
14
clojure.core=> 16re3
227
clojure.core=> 16r3e
62
clojure.core=> 0x3e
62
clojure.core=>  0x3e3
995
clojure.core=> 16r3e3
995

@jianlingzhong jianlingzhong force-pushed the integer branch 2 times, most recently from 0aa17e2 to 378f19f Compare December 3, 2024 07:30
@jianlingzhong jianlingzhong force-pushed the integer branch 6 times, most recently from cf7fc2d to b450179 Compare December 19, 2024 01:34
@jianlingzhong jianlingzhong requested a review from jeaye December 19, 2024 04:48
@jianlingzhong jianlingzhong requested a review from jeaye December 26, 2024 03:33
@jeaye jeaye merged commit 1ed299f into jank-lang:main Dec 26, 2024
2 of 3 checks passed
@jeaye
Copy link
Member

jeaye commented Dec 26, 2024

Great work, Jianling!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants